import java.util.List;
import java.util.*;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-12
 * Time:15:44
 * Text：找到两个字符串最少有多少相同的子序列
 */
public class Text17 {
    public static String findLongestSubsequence(String s, String t) {
        int m = s.length();
        int n = t.length();

        int[][] dp = new int[m + 1][n + 1];
        int maxLen = 0;
        int endIndex = 0;

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    if (dp[i][j] > maxLen) {
                        maxLen = dp[i][j];
                        endIndex = j;
                    }
                }
            }
        }

        String longestSubsequence = t.substring(endIndex - maxLen, endIndex);
        if (!longestSubsequence.isEmpty()) {
            return longestSubsequence;
        }
        return new String();
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s=scan.next();
        String t=scan.next();
        int ret=0;
        String longestSubsequence=new String();
        while(!t.equals(""))
        {
            ret++;
            longestSubsequence=findLongestSubsequence(s,t);
            //System.out.println(longestSubsequence);
            if (!longestSubsequence.isEmpty()) {
                t = t.replace(longestSubsequence, ""); // 从 t 字符串中删除最长连续子序列
            }else break;

        }
        if (longestSubsequence.isEmpty())  System.out.println(-1);
         else System.out.println(ret);
        scan.close();
    }

}


